package com.surfilter.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.surfilter.bean.GpsConfig;
import com.surfilter.bean.QueryResult;
import com.surfilter.service.GpsConfigService;

/**
 * @Author: lijia
 * @Date: Created in  2018-05-11 15:35
 * @Description:
 */
@Controller
public class GpsConfigController {

    @Autowired
    private GpsConfigService gpsConfigService;

    @RequestMapping("/gpsConfig")
    public String toVirtualType(){
        return "gpsConfigManager";

    }


    @RequestMapping("/gpsConfig/queryResult")
    @ResponseBody
    public Object getInfo(String page,String limit){

        QueryResult queryResult = new QueryResult();
//        queryResult.setAccount(account);
        queryResult.setPageNum(Integer.parseInt(page));
        queryResult.setLimit(Integer.parseInt(limit));
        return gpsConfigService.queryTypeResult(queryResult);

    }


    @RequestMapping(value = "/gpsConfig/delete/{id}",method = RequestMethod.POST)
    @ResponseBody
    public Object deteleVirtualTypeById(@PathVariable String id){
            int sum =  gpsConfigService.deteleVirtualTypeById(id);
            if (sum ==1){
                return 1;
            }else {
                return 0;
            }
    }

    @RequestMapping(value = "/gpsConfig/addGpsConfig",method = RequestMethod.POST)
    @ResponseBody
    public Object addGpsConfig(@RequestParam("filename") MultipartFile file,GpsConfig gpsConfig){
        return gpsConfigService.addVirtualtype(file,gpsConfig);
    }


}
